<?php

namespace App\Admin\Controllers;

use App\Http\Controllers\Controller;
use App\Model\Guild\GuildAccountMonly;
use Encore\Admin\Grid;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Controllers\ModelForm;
use Encore\Admin\Layout\Content;

/**
 * 代理结算-月报
 */
class GuildAccountMonlyController extends Controller
{
    use ModelForm;

    /**
     * Index interface.
     *
     * @return Content
     */

    public function index()
    {
        return Admin::content(function (Content $content) {
            $content->header('代理结算月报表');
            $content->description('');
            $content->body($this->grid());
        });
    }

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Admin::grid(GuildAccountMonly::class, function (Grid $grid) {
            $self = $this;
            $grid->model()->where(['flag' => 1])->orderBy('id', 'desc');
            $grid->mon('月份');
            $grid->guildInfo()->guild_id('代理ID');
            $grid->guildInfo()->name('代理名');
            $grid->active_host_num('在线女用户');
            $grid->income_host_num('收益女用户');
            $grid->total_turnover('总流水');
            $grid->voice_turnover('语音流水');
            $grid->video_turnover('视频流水');
            $grid->guild_share_income('代理分成（视频+语音）');
            $grid->host_share_income('女用户分成（视频+语音）');
            $grid->host_total_share('女用户总收入');

            //禁用导出
            $grid->disableExport();
            $grid->disableCreateButton();
            //禁用行选择
            $grid->disableRowSelector();
            $grid->filter(function ($filter) {
                $filter->equal('flag', '记录状态')->select([0 => '无效记录', 1 => '有效记录']);
            });

            $grid->actions(function (Grid\Displayers\Actions $actions) {
                $actions->disableDelete();
                $actions->disableView();
                $actions->disableEdit();
            });
        });
    }
}
